<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sp" uri="http://www.springframework.org/tags"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>My JSP 'add.jsp' starting page</title>

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3" />
<meta http-equiv="description" content="This is my page" />
<link href="/css/reset.css" rel="stylesheet" type="text/css" />
<link href="/css/common.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="/js/jquery_datapicker/themes/min/jquery.ui.all.min.css" />
<link rel="stylesheet" href="/js/jquery_datapicker/themes/min/jquery.ui.datepicker.min.css" />
<script type="text/javascript" src="/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="/js/formcheck/formcheck-0.0.1.js"></script>
<style type="text/css">
#tr_upload td {
	display: none;
	visibility: hidden;
}
</style>
</head>

<body class="mainframe">
  <form id="optionForm" action="/admin/option/edit.dhtml" method="post">
    <input type="hidden" id="questionId" name="option.id" value="<c:out value="${option.id }" />" />
    <input type="hidden" id="questionId" name="option.question.id" value="<c:out value="${option.question.id }" />" />
    <table class="admin_table">
      <caption>添加选项</caption>
      <c:choose>
        <c:when test="${message.info != null }">
          <tr>
            <td colspan="2"><sp:message code="${message.info}" text="" /></td>
          </tr>
        </c:when>
        <c:otherwise>
          <tr>
            <td>标题</td>
            <td><input type="text" id="optionTitle" name="option.title" value="<c:out value="${option.title }" />" /><span id="optionTitleTip"></span></td>
          </tr>
          <tr>
            <td>是否正确答案</td>
            <td><select name="option.isright">
                <option value="0" <c:out value="${ option.isright == 0?'selected=\"selected\"':''}" escapeXml="false" />>否</option>
                <option value="1" <c:out value="${ option.isright == 1?'selected=\"selected\"':''}" escapeXml="false" />>是</option>
            </select></td>
          </tr>
          <tr>
            <td>是否显示标题</td>
            <td><select name="option.showTitle">
                <option value="0" <c:out value="${ option.showTitle == 0?'selected=\"selected\"':''}" escapeXml="false" />>否</option>
                <option value="1" <c:out value="${ option.showTitle == 1?'selected=\"selected\"':''}" escapeXml="false" />>是</option>
            </select></td>
          </tr>
          <tr>
            <td>状态</td>
            <td><select name="option.stat">
                <option value="0" <c:out value="${ option.stat == 0?'selected=\"selected\"':''}" escapeXml="false" />>编辑</option>
                <option value="1" <c:out value="${ option.stat == 1?'selected=\"selected\"':''}" escapeXml="false" />>发布</option>
                <option value="2" <c:out value="${ option.stat == 2?'selected=\"selected\"':''}" escapeXml="false" />>停用</option>
            </select></td>
          </tr>
          <tr>
            <td>图片路径</td>
            <td><input type="text" id="uploadImg" name="option.img" value="<c:out value="${option.img }" />" /></td>
          </tr>
          <tr id="tr_upload">
            <td valign="top">上传资源</td>
            <td><iframe id="frame_upload" name="frame_upload" class="upload" width="400" height="200"
                src="/common/upload.dhtml?savePath=option/" scrolling="no" frameborder="0"></iframe></td>
          </tr>
          <tr>
            <td></td>
            <td><input type="submit" id="optionSubmit" value="添加" class="button01" /></td>
          </tr>
        </c:otherwise>
      </c:choose>
    </table>
  </form>
  <script type="text/javascript">
			// 表单验证
			var formCheck = $.formCheck();
			formCheck.regAllEmpty("optionTitle", {
				onShow : "输入目录名称",
				onFocus : "此项为必填",
				onError : "此项为必填",
				onCorrect : "目录名称输入正确"
			}, true);
			formCheck.formCheck("optionForm");
		</script>
</body>
</html>